package com.nowcode.community.mapper;

import com.nowcode.community.entity.LoginTicket;
import org.apache.ibatis.annotations.*;

/**
 * ClassName: LoginTicketMapper
 * Package: com.nowcode.community.mapper
 * Description:
 *
 * @Author: 信
 * @Create: 2024/1/22 - 19:36
 */
@Mapper
@Deprecated //TODO 21、不推荐使用
public interface LoginTicketMapper {

    @Insert(
            "insert into login_ticket(user_id,ticket,status,expired) " +
            "values(#{userId},#{ticket},#{status},#{expired})"
    )
    @Options(useGeneratedKeys = true, keyProperty = "id")  //TODO 9、主键自动生成
    int insertLoginTicket(LoginTicket loginTicket);

    @Select(
            "select id,user_id,ticket,status,expired " +
            "from login_ticket where ticket=#{ticket}"
    )
    LoginTicket selectByTicket(String ticket);

    @Update("update login_ticket set status=#{status} where ticket=#{ticket} ")
    int updateStatus(String ticket, int status);

}
